package com.esm.sm800.activity;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.esm.sm800.R;
import com.esm.sm800.util.ZazManager;

public class ZAZActivity extends Activity implements View.OnClickListener {

    // image variables
    EditText m_editUserID;
    Button m_btnEnroll;
    Button m_btnIdentify;
    Button m_btnDeleteID;

    TextView m_txtStatus;
    ImageView m_FpImageViewer;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_zaza);

        InitWidget();
        ZazManager.init(getBaseContext());
        ZazManager.getInstance().openDevice();
        ZazManager.getInstance().m_nUserID = 13;
    }

    protected void onResume() {
        super.onResume();
        ZazManager.getInstance().m_txtStatus = m_txtStatus;
        ZazManager.getInstance().m_FpImageViewer = m_FpImageViewer;
    }

    @Override
    protected void onPause() {
        super.onPause();
        ZazManager.getInstance().m_txtStatus = null;
        ZazManager.getInstance().m_FpImageViewer = null;
    }

    @Override
    public void onClick(View view) {
        if (view == m_btnEnroll)
            OnEnrollBtn();
        else if (view == m_btnIdentify)
            OnIdentifyBtn();
        else if (view == m_btnDeleteID)
            OnDeleteIDBtn();
    }

    private void InitWidget() {
        m_FpImageViewer = (ImageView) findViewById(R.id.imvImgViewer);
        m_btnEnroll = (Button) findViewById(R.id.btnEnroll);
        m_btnIdentify = (Button) findViewById(R.id.btnIdentify);
        m_btnDeleteID = (Button) findViewById(R.id.btnRemoveTemplate);
        m_txtStatus = (TextView) findViewById(R.id.txtStatus);
        m_editUserID = (EditText) findViewById(R.id.edtUserID);

        m_btnEnroll.setOnClickListener(this);
        m_btnIdentify.setOnClickListener(this);
        m_btnDeleteID.setOnClickListener(this);
    }

    //使用用户ID注册指纹模板
    private void OnEnrollBtn() {
        ZazManager.getInstance().enroll();
    }

    //搜索指纹
    private void OnIdentifyBtn() {
        ZazManager.getInstance().identify();

    }

    //删除用户ID的指纹模板
    private void OnDeleteIDBtn() {
        ZazManager.getInstance().deleteID();
    }


}
